﻿@{
    Layout = null;
}
@using ZHJ.PerfectOA.Model
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>SetUserRoleInfo</title>
    <script src="~/Scripts/jquery-1.8.2.min.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script type="text/javascript">
        function subForm() {
            //提交表单
            $("#setRoleForm").submit();
        }
        //调用父窗体中的afterSetUserRole方法
        function afterSet(data) {
            if (data == "ok") {
                window.parent.afterSetUserRole();
            }
        }
    </script>
</head>
<body>
    为 @{
        UserInfo userInfo = ViewBag.UserInfo;
        <span style="font-size:16px;color:red"> @userInfo.UName</span>
    } 分配角色
    @using (Ajax.BeginForm("SetUserRoleInfo", "UserInfo", new { }, new AjaxOptions() { HttpMethod = "post", OnSuccess = "afterSet" }, new { id = "setRoleForm" }))
    {
        <input type="hidden" name="userId" value="@userInfo.ID" />
        List<RoleInfo> roleInfoList = ViewBag.AllRole;
        List<int> roleIdList = ViewBag.AllRoleId;
        foreach (RoleInfo roleInfo in roleInfoList)
        {
            var roleName = "cba_" + roleInfo.ID;
            if (roleIdList.Contains(roleInfo.ID))
            {
                <input type="checkbox" name="@roleName" checked="checked" value="@roleInfo.ID" />@roleInfo.RoleName
            }
            else
            {
                <input type="checkbox" name="@roleName" value="@roleInfo.ID" />@roleInfo.RoleName
            }
        }
    }

</body>
</html>
